package com.util;

import javafx.scene.shape.Path;

import java.io.*;
import java.math.BigInteger;

/**
 * @authoer zsj
 * @date 2022/7/7 16:38
 */
public class ScannerReadTest {

    public static void main(String[] args) throws IOException {
        int ans = 0;
        try {
            String filePath = "E:\\primes.txt";
            File file = new File(filePath);
            if(file.isFile() && file.exists()) {
                InputStreamReader isr = new InputStreamReader(new FileInputStream(file), "utf-8");
                BufferedReader br = new BufferedReader(isr);
                String lineTxt = null;
                BigInteger max = new BigInteger("999870483413");
                while ((lineTxt = br.readLine()) != null) {
                    max = new BigInteger(String.valueOf(Long.parseLong(lineTxt))).min(max);
                }
                System.out.println(max);
                br.close();
            } else {
                System.out.println("文件不存在!");
            }
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println("文件读取错误!");
        }
    }
}
